if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_CongNo_Insert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_CongNo_Insert]
GO

create PROC [dbo].[sp_CongNo_Insert]
	@Ma_khach_hang Int,
	@Ma_loai_cong_no Int,
	@Thanh_toan float,
	@Ma_ngoai_te int,
	@Ty_gia float,
	@Thanh_tien float,
	@Ghi_chu nvarchar(100)
as
BEGIN
	DECLARE @Ngay_cap_nhat_cuoi datetime
	SET @Ngay_cap_nhat_cuoi = getdate()
	INSERT INTO CongNo(
					Ma_khach_hang,
					Ma_loai_cong_no,
					Thanh_toan,
					Ma_ngoai_te,
					Ty_gia,
					Thanh_tien,					
					Ghi_chu,
					Ngay_cap_nhat_cuoi
				)
	VALUES(				
		@Ma_khach_hang,
		@Ma_loai_cong_no,
		@Thanh_toan,
		@Ma_ngoai_te,
		@Ty_gia,
		@Thanh_tien,					
		@Ghi_chu,
		@Ngay_cap_nhat_cuoi
	)
END
